package com.ouc.yyi.test03;

import java.util.Scanner;

public class Goods {
    String goods[] = new String[]{"电风扇","洗衣机","电视剧","冰箱","空调"};
    //double prices[] = new double[]{124.23,4500.0,8800.9,5000.88,4456.0};
    String prices[] = new String[]{"124.23","4,500.0","8,800.9","5,000.88","4,456.0"};

    //登陆
    public boolean login(String name,String password){
        boolean isRegister = false;
        if(name.equals("Tom")&&password.equals("123456")){
            isRegister = true;
            System.out.println("登陆成功！");
        }
        return isRegister;
    }

    //批发商品总金额
    public double buy(int no,int num){
        //double total = prices[no-1]*num;
        Scanner input = new Scanner(System.in);
        System.out.print("请输入你选择编号为"+no+"的商品价格：");
        double price = input.nextDouble();
        double total = price*num;
        return total;
    }

    //显示上商品信息
    public void showGoods(){
        System.out.println("********欢迎进入商品批发城********");
        System.out.println("\t编号\t商品\t价格");
        int num[] = new int[]{1,2,3,4,5};

        for(int i=0;i<num.length;i++){
        System.out.print("\t"+num[i] +"\t"+goods[i]+"\t"+prices[i]+"\n");
    }
  System.out.println("*********************************");
}
    //总金额输出处理
    public StringBuffer change(double total){
        StringBuffer sb = new StringBuffer(String.valueOf(total));
        for(int i=sb.indexOf(".")-3;i>0;i=i-3){
            sb.insert(i,",");
        }
        return sb;
    }
}
